﻿<%@ Page Title="" Language="C#" MasterPageFile="~/_Default.Master" AutoEventWireup="true" CodeBehind="Detail.aspx.cs" Inherits="WebApplication.Project.Detail" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <link href="../Content/Css/projectDetail.css" rel="stylesheet" />
    <style>
        .layui-panel .artist-item .intro {
            height: auto;
            margin: 10px 0;
            overflow: hidden;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="layui-row layui-col-space15 project-container">
        <div class="layui-col-sm8">
            <div class="layui-panel">
                <div class="layui-panel-body">
                    <div class="header">
                        <div class="title">
                            [<%=project.IsDeadLine ? "已截稿":"进行中" %>] <%=project.Title %>
                            <span class="status"><%=project.IsDeadLine ? "已截稿":"进行中" %></span>
                        </div>
                        <div class="created">
                            发布于<%=project.CreatedAt %>
                        </div>

                    </div>

                    <% foreach (string tag in tags)
                        { %>
                    <span class="el-tag el-tag--info el-tag--light" style="cursor: pointer;"><%=tag %></span>
                    <%} %>


                    <div class="app-divider" style="margin: 20px 0px;">
                        <b class="left"></b>
                        <span class="text normal"></span><b class="right"></b>
                    </div>

                    <div class="inset-content" style="font-size: 16px; font-weight: bold;">
                        <div class="label-wrapper"><span class="label">单张预算：</span><span class="value"><%=project.PriceMin %>元 - <%=project.PriceMax %>元</span></div>
                        <div class="label-wrapper">
                            <span class="label">截稿日期：</span><span class="value"><%=project.Deadline.ToString("yyyy-MM-dd") %></span>
                        </div>
                        <div class="label-wrapper" style="display: none;">
                            <span class="label">合作流程：</span><span class="value">由我选定画师自行联系</span>
                        </div>
                    </div>

                    <div class="html-content mt1" id="html-content">
                        <%=project.Content %>
                    </div>

                   
                    

                    <% if (project.OwnerID != Convert.ToInt32(Session["UID"]))
                        { %>

                    <% if (!project.IsDeadLine)
                        { %>
                    <div class="mt1">
                        <button id="applyBtn" type="button" class="el-button el-button--primary">
                            <% if (!project.IsApply)
                                { %>
                            <span>我要应征</span>
                            <%}
                                else
                                { %>
                            <span>取消应征</span>
                            <%} %>
                        </button>
                    </div>

                    <script>
                        $('#applyBtn').on('click', e => {
                            $.ajax({
                                url: "/Project/Handle.aspx",
                                method: "post",
                                data: {
                                    action: "Apply",
                                    id: utils.getQueryVariable('id')
                                },
                                success: (res) => {
                                    location.reload();
                                }
                            })
                        })
                    </script>
                    <%} %>

                    <%}
                        else
                        { %>
                     <div class="flex-container mt1" style="justify-content:flex-end;align-items:center;">
                        <a href="Edit.aspx?mode=edit&id=<%=project.ProjectID %>">
                            <div class="layui-btn layui-btn-danger-2">修改</div>
                        </a>
                        <span class="ml-10 pointer" id="deleteBtn" data="<%=project.ProjectID %>">删除</span>
                    </div>

                    <script>
                        $(function () {
                            $('#deleteBtn').on('click', (e) => {
                                layer.confirm('确定要删除该需求嘛?', function (index) {
                                    let id = $(e.target).attr("data");

                                    $.ajax({
                                        url: '/Project/Handle.aspx',
                                        method: "post",
                                        data: {
                                            action: 'Delete',
                                            id
                                        },
                                        success: () => {
                                            location.href = "/"
                                        }
                                    })
                                    layer.close(index);
                                });
                            })
                        })
                    </script>
                    <%} %>
                </div>
            </div>
        </div>

        <div class="layui-col-sm4">

            <div class="layui-panel">
                <div class="user-card">
                    <a href="/User/Arts.aspx?id=<%=project.OwnerID %>" class="">
                        <span class="avatar" style="width: 60px; height: 60px;">
                            <img src="<%=project.Owner.AvatarUrl.Substring(1, project.Owner.AvatarUrl.Length - 1) %>" />
                        </span>
                    </a>
                    <div class="nickname">
                        <a href="/User/Arts.aspx?id=<%=project.OwnerID %>" class=""><%=project.Owner.NickName %>&nbsp;
                            <i class="iconfont <%=project.Owner.Sex==1?"icon-nv":project.Owner.Sex==2?"icon-nan":"" %>" style="font-size: 16px;"></i>
                        </a>
                    </div>
                    <div class="intro">
                        <%=project.Owner.Intro %>
                    </div>
                </div>
            </div>

            <div class="layui-panel mt1">
                <div style="padding: 20px;">
                    <div class="label-wrapper">
                        <span class="label">身份：</span>
                        <% if (project.Identity == 1)
                            {%>
                        <span class="value">私人</span>
                        <%} %>
                        <% if (project.Identity == 2)
                            {%>
                        <span class="value">社团/店铺</span>
                        <%} %>
                        <% if (project.Identity == 3)
                            {%>
                        <span class="value">公司企业</span>
                        <%} %>
                    </div>
                    <div class="label-wrapper">
                        <span class="label">名称：</span>
                        <span class="value">
                            <%=(project.Name==""||project.Name==null)?"未填写":project.Name %>
                        </span>
                    </div>
                </div>
            </div>

        </div>



        <div class="layui-col-sm12 layui-col-space10">

            <% foreach (Models.ProjectArtists projectArtists in projectArtists)
                {%>
            <div class="layui-col-sm6">
                <div class="layui-panel">
                    <div class="artist-item">
                        <div class="artist-header horizontal-layout">
                            <a href="/User/Arts.aspx?id=<%=projectArtists.OwnerID %>" target="_blank">
                                <span class="avatar wrap" style="width: 60px; height: 60px; cursor: pointer;">
                                    <img
                                        src="<%=projectArtists.Owner.AvatarUrl.Substring(1) %>"" />
                                </span>
                            </a>
                            <div class="info match">
                                <div class="nickname-wrapper">
                                    <span class="nickname"><%=projectArtists.Owner.NickName %>&nbsp;
                                        <i class="iconfont <%=projectArtists.Owner.Sex==1?"icon-nv":projectArtists.Owner.Sex==2?"icon-nan":"" %>" style="font-size: 16px;"></i>
                                    </span>
                                    <div class="lmid">
                                        <span class="prefix">联盟ID</span><span class="id"><%=projectArtists.OwnerID %></span>
                                    </div>
                                </div>
                                <div class="tags">
                                    <%
                                        string resumeTag = projectArtists.ResumeInfo.Tag;
                                        if (resumeTag == null)
                                        {
                                            resumeTag = "[]";
                                        };

                                        List<string> tags = Newtonsoft.Json.JsonConvert.DeserializeObject<List<string>>(resumeTag);

                                        if (tags.Count > 0)
                                        {
                                            tags.Remove("@");
                                        }

                                        foreach (string tag in tags)
                                        {
                                        %>
                                    <span class="el-tag el-tag--info el-tag--mini el-tag--light"><%=tag %>
                                    </span>
                                    <%} %>

                                </div>
                            </div>

                            <a href="../Resume.aspx?id=<%=projectArtists.OwnerID %>" target="_blank" class="el-button el-button--warning">
                                <span>
                                    TA的接稿页
                                </span>
                            </a>
                        </div>
                        <div class="intro flex-container">
                            <div class="label-wrapper flex-container">
                                <div class="label">接稿经验：</div>

                                <div class="value"><%=(projectArtists.ResumeInfo.Experience == null || projectArtists.ResumeInfo.Experience=="")?"未填写":projectArtists.ResumeInfo.Experience %></div>
                            </div>
                            <div class="label-wrapper flex-container ml-10">
                                <div class="label">联系方式：</div>
                                <div class="value"><%=(projectArtists.ResumeInfo.Contact == null || projectArtists.ResumeInfo.Contact=="")?"未填写":projectArtists.ResumeInfo.Contact %></div>
                            </div>
                        </div>
                        <div class="layui-row layui-col-space10">

                            <% if (projectArtists.Artworks.Count > 0)
                                { %>
                                <% foreach (Models.Artworks artwork in projectArtists.Artworks.Take(4))
                                    { %>
                                    <div class="layui-col-sm3" style="float: right;">
                                            <div class="art-item">
                                                <a style="display:block;" href="../Art/Detail.aspx?id=<%=artwork.ArtworkID %>" target="_blank">
                                                    <div class="cover-wrapper"
                                                        style="background-image: url(<%=artwork.Cover.Substring(1)%>); height: 200px;">
                                                    </div>
                                                </a>
                                            </div>
                                    </div>
                                <%} %>
                            <%}
                                else
                                { %>
                            <div style="height:207px;display:flex;align-items:center;justify-content:center;">
                                暂无作品
                            </div>
                            <%} %>

                        </div>
                    </div>
                </div>
            </div>

            <%} %>

        </div>

    </div>
</asp:Content>
